#include "stdafx.h"
#include "QModelViewer.h"

QModelViewer::QModelViewer(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	ui.setupUi(this);
	m_pModelWidget = new ModelWidget(this);
	m_pModelWidget->setModelViewer(this);
	m_pModelWidget->Go();
	this->setCentralWidget(m_pModelWidget);

	QDockWidget* pDock = new QDockWidget(this);
	m_pFolderViewer = new FolderViewer(pDock);
	m_pFolderViewer->setQModelViewer(this);
	pDock->setWidget(m_pFolderViewer);
	pDock->setAllowedAreas(Qt::AllDockWidgetAreas);
	this->addDockWidget(Qt::LeftDockWidgetArea, pDock);

	pDock = new QDockWidget(this);
	m_pModelInfo = new ModelInfo(pDock);
	m_pModelInfo->setQModelViewer(this);
	pDock->setWidget(m_pModelInfo);
	pDock->setAllowedAreas(Qt::AllDockWidgetAreas);
	this->addDockWidget(Qt::RightDockWidgetArea, pDock);

}

QModelViewer::~QModelViewer()
{

}

void QModelViewer::loadEntity(const QString& meshName)
{
	m_pModelWidget->loadEntity(meshName);
}

void QModelViewer::setMaterialNames(const QStringList& nameList)
{
	m_pModelInfo->setMaterialNames(nameList);
}

void QModelViewer::setSkeletonName( const QString& skeletonName )
{
	m_pModelInfo->setSkeletonName(skeletonName);
}

void QModelViewer::setAnimations( const QStringList& aniNameList )
{
	m_pModelInfo->setAnimations(aniNameList);
}

void QModelViewer::playAnimation( const QString& aniName, bool isLoop, Ogre::Real speed )
{
	m_pModelWidget->playAnimation(aniName, isLoop, speed);
}
